package com.yonyou.iuap.ipaas.connector.sdwcoatencent.internal.operation;

import cn.hutool.json.JSONUtil;
import com.yonyou.iuap.ipaas.connector.sdk.api.model.ResponseAttributes;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.api.model.common.PageableData;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.api.model.common.UrlConstant;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.api.model.request.purchase.PurReturnQueryRequest;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.api.model.request.stock.InboundListQueryRequest;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.api.model.response.purchase.PurReturnQueryResponse;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.api.model.response.stock.InboundListQueryResponse;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.internal.LxwcoatencentConnection;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.internal.exception.ExecuteErrorsProvider;
import com.yonyou.iuap.ipaas.connector.sdwcoatencent.internal.utils.JSON;
import com.yonyou.yonlinker.ysb.runtime.extension.api.annotation.error.Throws;
import com.yonyou.yonlinker.ysb.runtime.extension.api.annotation.param.Connection;
import com.yonyou.yonlinker.ysb.runtime.extension.api.annotation.param.Content;
import com.yonyou.yonlinker.ysb.runtime.extension.api.annotation.param.MediaType;
import com.yonyou.yonlinker.ysb.runtime.extension.api.runtime.operation.Result;

@Throws(ExecuteErrorsProvider.class)
public class PurchaseOperations {

    /**
     * 采购入库列表查询
     * @param connection
     * @param inboundListQueryRequest
     * @return
     */
    @MediaType(
            strict = false,
            value = "application/json"
    )
    public Result<String, ResponseAttributes> queryPurInList(@Connection LxwcoatencentConnection connection, @Content InboundListQueryRequest inboundListQueryRequest) {
        PageableData<InboundListQueryResponse> result = connection.doQuery(UrlConstant.INBOUND_QUERY_URL, JSONUtil.parseObj(inboundListQueryRequest));
        return connection.returnCommonResult("queryPurInList", result);
    }

    /**
     * 采购退货列表查询
     * @param connection
     * @param purReturnQueryRequest
     * @return
     */
    @MediaType(
            strict = false,
            value = "application/json"
    )
    public Result<String, ResponseAttributes> queryPurReturnList(@Connection LxwcoatencentConnection connection, @Content PurReturnQueryRequest purReturnQueryRequest) {
        PageableData<PurReturnQueryResponse> result = connection.doQuery(UrlConstant.PURCHASE_RETURN_QUERY_URL, JSONUtil.parseObj(purReturnQueryRequest));
        return connection.returnCommonResult("queryPurReturnList", result);
    }
}
